﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;
using System.Diagnostics.CodeAnalysis;

namespace Isuka.Spiritual
{
    public partial interface IRule<T, A>
        where T : IEquatable<T>
        where A : class
    {
        Rules<T, A>.RuleFunc Rule { get; }
    }

    #region IRule contract binding
    [ContractClass(typeof(IRuleContract<,>))]
    public partial interface IRule<T, A> { }

    [ContractClassFor(typeof(IRule<,>))]
    abstract class IRuleContract<T, A> : IRule<T, A>
        where T : IEquatable<T>
        where A : class
    {
        [ContractInvariantMethod]
        [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Justification = "Required for code contracts.")]
        private void ObjectInvariant()
        {
            Contract.Invariant(Rule != null);
        }

        #region IRule<T,A> メンバー

        public Rules<T, A>.RuleFunc Rule
        {
            get
            {
                Contract.Ensures(Contract.Result<Rules<T, A>.RuleFunc>() != null);
                throw new NotImplementedException();
            }
        }

        #endregion

    }

    #endregion

}
